<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="bill" class="com.divudi.entitity.Bill"  />
        <cc:attribute name="duplicate" />
        <cc:attribute name="cancelled" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>

        <h:outputStylesheet library="css" name="pharmacypos.css" ></h:outputStylesheet>
        <div class="posbillBreak">


            <div class="institutionName" style="text-align: center!important;
                 font-weight: bold!important;
                 font-size: 18px!important;
                 font-weight: bold;">
                <h:outputLabel value="#{cc.attrs.bill.department.printingName}" />
            </div>
            <div class="institutionContact" >
                <div>
                    <h:outputLabel value="#{cc.attrs.bill.department.address}"/>
                </div>
                <div >
                    <h:outputLabel value="#{cc.attrs.bill.department.telephone1} "/>
                    <h:outputLabel value="#{cc.attrs.bill.department.telephone2}"/>
                </div>
                <div >
                    <h:outputLabel value="#{cc.attrs.bill.department.fax}"/>                                                 
                </div>
            </div>

            <div class="headingBill">
                <h:outputLabel value="INVOICE"   />    
                <h:outputLabel value="**Duplicate**"  rendered="#{cc.attrs.duplicate eq true}" /> 
                <h:outputLabel value="**Cancelled**"  rendered="#{cc.attrs.bill.cancelled eq true}" /> 
            </div>

            <div class="billline">
                <h:outputLabel value="-----------------------------------------------"   />                           
            </div>

            <div class="billDetails" >
                <table style="width: 100%; margin-left:0.5cm;" >
                    <tr>
                        <td style="width: 15%; text-align: left;" >
                            <h:outputLabel value="Date" style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                        </td>
                        <td>:</td>
                        <td style="width: 85%" >
                            <h:outputLabel value="#{cc.attrs.bill.createdAt}" style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;">
                                <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                            </h:outputLabel>
                        </td>
                    </tr>

                    <tr>
                        <td style="width: 15%; text-align: left;" >
                            <h:outputLabel value="Time" style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                        </td>
                        <td>:</td>
                        <td style="width: 30%" >
                            <h:outputLabel value="#{cc.attrs.bill.createdAt}"  style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;">
                                <f:convertDateTime pattern="hh:mm a" ></f:convertDateTime>
                            </h:outputLabel>
                        </td>
                    </tr>


                    <tr>
                        <td style="width: 15% ;text-align: left;" >
                            <h:outputLabel value="Inv.No" style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                        </td>
                        <td>:</td>
                        <td style="width: 30%;" >
                            <h:outputLabel value="#{cc.attrs.bill.insId}"  style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;">
                            </h:outputLabel>
                        </td>
                    </tr>

                    <tr>
                        <td style="width: 15% ;text-align: left;" >
                            <h:outputLabel value="Method" style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                        </td>
                        <td>:</td>
                        <td style="width: 30%;" >
                            <h:outputLabel value="#{cc.attrs.bill.paymentMethod}"  style="text-align: center!important;   
                                           font-size: 12px!important;
                                           font-family:Arial, Helvetica, sans-serif!important;">
                            </h:outputLabel>
                        </td>
                    </tr>

                    <h:panelGroup rendered="#{cc.attrs.bill.patient ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Name" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.patient.person.nameWithTitle}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.patient ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Phone" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.patient.person.phone}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.patient ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Age" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.patient.age}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.referredBy ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Ref. Doctor" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.referredBy.person.name}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>

                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.referredByInstitution ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Col. Center" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.referredByInstitution.name}" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;" >
                                </h:outputLabel>
                            </td>

                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.toStaff ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Staff Name" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.toStaff.person.nameWithTitle}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>

                        </tr>
                    </h:panelGroup>




                    <h:panelGroup rendered="#{cc.attrs.bill.toDepartment ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Department" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.toDepartment.name}"  style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>

                        </tr>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.creater.staff.code ne null}" >
                        <tr>
                            <td style="width: 15% ;text-align: left;" >
                                <h:outputLabel value="Billed by" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;"></h:outputLabel>
                            </td>
                            <td>:</td>
                            <td style="width: 30%;" >
                                <h:outputLabel value="#{cc.attrs.bill.creater.staff.code}" style="text-align: center!important;   
                                               font-size: 12px!important;
                                               font-family:Arial, Helvetica, sans-serif!important;">
                                </h:outputLabel>
                            </td>
                        </tr>
                    </h:panelGroup>


                </table>


            </div>





            <div >

                <table width="100%" style="width: 100%; margin-left:0.5cm;  ">
                    <tr>
                        <td colspan="2" class="billline">
                            <hr/>                          
                        </td>
                    </tr>
                    <tr>
                        <td >
                            <h:outputLabel value="ITEM" styleClass="itemHeadings" ></h:outputLabel>
                        </td>

                        <td  style="width:30%;text-align: right; padding-right: 30px;">
                            <h:outputLabel value="VALUE"  styleClass="itemHeadings" ></h:outputLabel>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="2" class="billline">

                            <hr/>                       
                        </td>
                    </tr>



                    <ui:repeat value="#{cc.attrs.bill.billItems}" var="bip" >

                        <tr>
                            <td colspan="4" style="overflow: visible;">
                                <h:outputLabel value="#{bip.item.printName}"  styleClass="itemsBlock" style="text-transform: capitalize!important;"  >
                                </h:outputLabel>
                            </td>
                            <td  styleClass="itemsBlockRight" style="text-align: right; padding-right: 30px;" >
                                <h:outputLabel    value="#{bip.grossValue}"    >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>

                        </tr>




                    </ui:repeat>




                </table>


            </div>


            <div class="billline">
                <h:outputLabel value="-----------------------------------------------"   />                           
            </div>



            <div  >

                <table style="width: 100%; margin-left:0.5cm; ">


                    <h:panelGroup rendered="#{cc.attrs.bill.balance gt 4.0 }" >

                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;" >
                                <h:outputLabel value="Value" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.total}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>

                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;">
                                <h:outputLabel value="Paid" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.cashPaid}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>

                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;">
                                <h:outputLabel value="To be Paid" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.balance}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>

                    </h:panelGroup>

                    <h:panelGroup rendered="#{cc.attrs.bill.balance lt 5.0 }" >

                        <tr>
                            <td class="totalsBlock" style="text-align: left; width: 60%;">
                                <h:outputLabel value="Total" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; width: 40%; padding-right: 30px;">
                                <h:outputLabel value="#{cc.attrs.bill.total}" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>                        

                        <tr>
                            <td  class="totalsBlock" style="text-align: left;">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}" value="Discount " style="font-weight: bolder!important;"/>
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important; ; padding-right: 30px;">
                                <h:outputLabel rendered="#{cc.attrs.bill.discount ne 0.0}"   value="#{-cc.attrs.bill.discount}" style="font-weight: bolder!important;" >
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>
                            </td>
                        </tr>
                        <tr>
                            <td  class="totalsBlock" style="text-align: left;">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="Net Total" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important;font-weight: bold; ; padding-right: 30px; ">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="#{cc.attrs.bill.netTotal}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                          
                            </td>                        
                        </tr>

                        <tr>
                            <td  class="totalsBlock" style="text-align: left;">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discount ne 0.0}"    value="VAT" />
                            </td>
                            <td  class="totalsBlock" style="text-align: right!important;font-weight: bold; ; padding-right: 30px; ">
                                <h:outputLabel  rendered="#{cc.attrs.bill.vat ne 0.0}"    value="#{cc.attrs.bill.vat}">
                                    <f:convertNumber pattern="#,##0.00" />
                                </h:outputLabel>                          
                            </td>                        
                        </tr>

                        <tr>

                            <td  class="totalsBlock" style="text-align: left;">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discountPercentPharmacy ne 0.0}" value="Discount Percent" style="font-weight: bolder!important;"/>
                            </td>

                            <td  class="totalsBlock" style="text-align: right!important;font-weight: bold; ; padding-right: 30px; ">
                                <h:outputLabel  rendered="#{cc.attrs.bill.discountPercentPharmacy ne 0.0}"    value="#{cc.attrs.bill.discountPercentPharmacy} %">
                                    <f:convertNumber pattern="#,##0.0" />
                                </h:outputLabel>


                            </td>
                        </tr>


                    </h:panelGroup>

                </table>

            </div>

            <div>
                <h:outputLabel value="" ></h:outputLabel>  
                <h:outputLabel value="" ></h:outputLabel>
                <h:outputLabel value="Signature :"> </h:outputLabel>  
                <h:outputLabel value="" ></h:outputLabel>  
                <h:outputLabel value="" ></h:outputLabel>  
            </div>

            <div class="footer">
                <br/>
                The Greatest Wealth is Health!
                <h:panelGroup  rendered="#{sessionController.loggedPreference.pharmacyBillFooter ne null}">
                    <br/>
                </h:panelGroup>
                <h:outputLabel value="#{sessionController.loggedPreference.pharmacyBillFooter}" ></h:outputLabel>
            </div>



        </div>
    </cc:implementation>
</html>
